import DesignDragAction from '@/components/hhd/design/FormDesigner/action/DesignDragAction';
import LayoutDesignAction from '@/components/hhd/design/FormDesigner/action/LayoutDesignAction';
const action = {
  bind(root, formDefinition, config) {
    this.dragAction = new FormDesignAction(root, formDefinition, config).bind();
    this.layoutAction = new LayoutDesignAction(root, formDefinition, config).bind();
    return this;
  },
  setSelectedField(selectedField) {
    this.dragAction && this.dragAction.setSelectedField && this.dragAction.setSelectedField(selectedField);
  }
};
export default action
class FormDesignAction {
  root
  formDefinition
  constructor(root, formDefinition, config) {
    this.root = root;
    this.formDefinition = formDefinition;
    this.config = config;
  }

  setSelectedField(selectedField) {
    this.dragAction && this.dragAction.setSelectedField && this.dragAction.setSelectedField(selectedField);
  }

  bind() {
    this.dragAction = new DesignDragAction(this).bind({
      reBind: () => action.bind(this.root, this.formDefinition, this.config),
      ...this.config
    });
    return this;
  }
}